<template>
	<view class="content">
		<uni-card title="我的账号列表" thumbnail="" extra="已绑定账号" note="Tips" is-full>
			<uni-list>
				<uni-list-item v-for="item in userlist" :title="item.email" link @click="myClick(item)"></uni-list-item>
			</uni-list>
		</uni-card>
		<view class="uni-btn-v">
			<button type="primary" @click="clear">清空我的数据</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userlist:[]
			} 
		},
		onShow() {
			let userliststr = uni.getStorageSync('userlist');
			if(userliststr!=null){
				this.userlist = JSON.parse(userliststr);
			}
		},
		onLoad() {
			let userliststr = uni.getStorageSync('userlist');
			if(userliststr!=null){
				this.userlist = JSON.parse(userliststr);
			}
		},
		methods: {
			myClick(item){
				uni.navigateTo({
					url: '/pages/me/index/tokengen/tokengen?email='+item.email+'&secret='+item.secret
				});
			},
			clear(){
				let that = this;
				uni.showModal({
					content: "确认要清除绑定的账号码？",
					confirmText: "确认",
					success: function(res) {
						if (res.confirm) {
							try {
								uni.setStorageSync('userlist', "");
								that.userlist = [];
							} catch (e) {
								// error
							}
						}
					}
				});
			}
		}
	}
</script>

<style>
.content{
	padding: 20rpx;
}
</style>
